rm(list=ls())
##############################################################################
# APPENDIX REPLICATION
##############################################################################
# setwd to replication file
setwd("~/Library/CloudStorage/GoogleDrive-cjoycebryan@gmail.com/My Drive/Cyber proxies - ITU /replication")
###########################
# INSTALL + LOAD PACKAGES #
###########################
install.packages(c("texreg", "ggplot2", "glm.predict", "mice", "MASS",
"maps", "tidyverse", "countrycode", "AER", "kableExtra"))
lapply(c("texreg", "ggplot2", "glm.predict", "mice", "MASS",
"maps", "tidyverse", "countrycode", "AER", "kableExtra"), require, character.only = TRUE)
###############
# RUN SCRIPTS #
###############
source("append_scripts/appendB1_fig1.R")
source("append_scripts/appendB1_tab1.R")
source("append_scripts/appendB2_tab1.R")
source("append_scripts/appendB3_tab1.R")
source("append_scripts/appendB3_tab2.R")
source("append_scripts/appendB3_tab3.R")
source("append_scripts/appendB4_tab1.R")
source("append_scripts/appendB5_tab1.R")
source("append_scripts/appendB6_tab1.R")
source("append_scripts/appendB7_tab1.R")
rm(list=ls())
##############################################################################
# APPENDIX B6 TABLE 1
##############################################################################
# load packages
#library(texreg)
#library(mice)
# load data
load("data/eurepoc_year_attacks.RData")
load("data/imputed_data_year.RData")
##############
# RUN MODELS #
##############
#model 1 (eurepoc attacks incidents)
m1 <- lm(attacks ~ treat + factor(ccode) + factor(spell), data = eurepoc_year_data)
#model 2 (eurepoc attacks control)
d.long$log_tech_articles <- log(d.long$tech_articles + 1)
imp.candidates <- as.mids(d.long)
fit.A <- with(imp.candidates, lm(attacks ~ treat + factor(ccode) + factor(spell) +
internet_usage + ict_exports + log_tech_articles))
m2 <- pool(fit.A)
################
# CREATE TABLE #
################
appendB6_tab1 <- screenreg(list(m1, m2), custom.coef.map = list("treat" = "candidate",
"internet_usage" = "internet usage",
"ict_exports" = "ICT exports",
"log_tech_articles" = "log tech articles"),
omit.coef = c("country_spell"),
custom.gof.rows = list("Country FE" = c("YES", "YES"), "Spell FE" = c("YES", "YES")),
digits = 3, stars = c(0.001, 0.01, 0.05, 0.1))
print(appendB6_tab1)
